﻿@inherits FeedbackComponent<int, bool>
<Spin Spinning="_importLoading">
    <Row>
        <AntDesign.Col Span="6">
            <Select DataSource="apiInfos"
                    @bind-Value="@_selectedGroupValue"
                    ValueName="@nameof(SwaggerSpecificationOpenApiInfoDto.Group)"
                    LabelName="@nameof(SwaggerSpecificationOpenApiInfoDto.Title)"
                    DefaultActiveFirstOption
                    Style="width: 100%;"
                    Size="@InputSize.Large"
                    OnSelectedItemChanged="OnSelectedItemChangedHandler">
                <ItemTemplate>
                    <span>@((context as SwaggerSpecificationOpenApiInfoDto).Title)</span>
                </ItemTemplate>
            </Select>
        </AntDesign.Col>
        <AntDesign.Col Span="16">
            <Input Placeholder="swagger json url"
                   Style="width:100%;"
                   Size="@InputSize.Large"
                   @bind-Value="@_apiJsonUrl" />
        </AntDesign.Col>
        <AntDesign.Col Span="2">
            <Button Style="width:100%" Type="@ButtonType.Primary" Size="@ButtonSize.Large" Loading="_loading" OnClick="OnLoad">@localizer["加载"]</Button>
        </AntDesign.Col>

    </Row>
    <Row Style="margin-top:10px;">
        <AntDesign.Col>
            <Table DataSource="@_functionDtos"
                   TItem="FunctionDto"
                   PageSize="_functionDtos.Count()"
                   Loading="@_loading"
                   Context="model"
                   Size=@TableSize.Small
                   ScrollY="600px"
                   HidePagination="true"
                   Bordered="true"
                   SelectedRows="@_selectedFunctionDtos"
                   SelectedRowsChanged="SelectedRowsChanged">
                <Selection Key="@(model.Path+"_"+model.Method)" />
                <Column @bind-Field="@model.Service" Width="150" Sortable="false" Filterable OnFilter="((value,name)=>name.Equals(value))"/>
                <Column @bind-Field="@model.Summary" Width="150" Sortable="false" Filterable/>
                <Column @bind-Field="@model.Description" Width="200" Sortable="false" Filterable/>
                <Column @bind-Field="@model.Path" Width="150" Sortable="false" Filterable/>
                <Column @bind-Field="@model.Method" Width="100" Sortable="false"  Filters="TableFiltersConstants.FunctionMethodFilters">
                    <TagRandomColor Text="@EnumHelper.GetEnumDescription(model.Method)"></TagRandomColor>
                </Column>
                <Column @bind-Field="@model.EnableAudit" Width="100" Sortable="false">
                    <Switch @bind-Value="@model.EnableAudit" OnChange="e=>OnChangeEnableAudit(model,e)"></Switch>
                </Column>
            </Table>
        </AntDesign.Col>
    </Row>
</Spin>
<Row style="height:30px;width:100%">
    @if (_importIsBegin)
    {
        <Progress Percent=_importPercent />
    }
</Row>
<Row>
    <AntDesign.Col Span="8" Offset="8">
        <Space>
            <SpaceItem>
                <Tooltip Placement="@Placement.Top" Title="@(localizer["导入"])">
                    <Button Type="@ButtonType.Primary" OnClick="OnImportClick" Loading="_importLoading">
                        @localizer["导入"]
                    </Button>
                </Tooltip>
                <Button Type="@ButtonType.Default" OnClick="OnCancleClick">
                    @localizer["关闭"]
                </Button>
            </SpaceItem>
        </Space>
    </AntDesign.Col>
</Row>